import React , { Component } from 'react';
import Child from './child.jsx';

class View extends Component{
    constructor(props){
        super(props);
        this.state = {
            testName:'66666'
        }
    }
    setFn(e,test){
        console.log(e,test)
        this.setState({
            testName:test
        })
    }
    render(){
        return (
            <React.Fragment>
                这是子组件如何往父({this.state.testName})组件传值或操作父组件方法
                官方术语叫状态提升。
                <br/>
                <Child callback = {(e,test)=>this.setFn(e,test)}/>
                <Child callback = {this.setFn.bind(this)}/>
                <br/>
            </React.Fragment>
        )
    }

}
export default View;
